'use strict';

/**
 * @ngdoc function
 * @name jgappApp.controller:WarehouseListCtrl
 * @description
 * # WarehouseListCtrl
 * Controller of the jgappApp
 */
angular
  .module("jgappApp")
  .controller("WarehouseListCtrl", function (
    $scope,
    Util,
    openApi,
    PagingService
  ) {
    var relModuleObj;

    relModuleObj = Util.getDataforsearch();
    $scope.choosePeople = function (index) {
      $scope.submit(index);
    };
    $scope.submit = function (index) {
      if ($scope.taskList.items) {
        var select = $scope.taskList.items[index];
        // relModuleObj包含用来回显的值以及返回的内容
        relModuleObj.filterData = {
          warehouseId: select.pkId,
          projectId: select.projectId,
          warehouseName: select.name
        };
        Util.savaDataforsearch(relModuleObj);
        Util.goBack();
      }
    };

    $scope.search = function (input) {
      var param = {};
      param.name = input;
      $scope.taskList = new PagingService(openApi.materialWarehouse, param);
    };
    $scope.search();
  });
